#!/bin/bash

data[0]='http://127.0.0.1:8002/portal/runCheck'
data[1]='http://127.0.0.1:8003/manager/runCheck'
#hostname=`more $(dirname $(dirname $(pwd)))/cfg.json | grep 'hostname' | sed -r 's/.*\"(.+)\".*/\1/'`
hostname=`more $(pwd)/cfg.json | grep 'hostname' | sed -r 's/.*\"(.+)\".*/\1/'`
ts=`date +%s`
for url in ${data[@]}
do
   {
        #curl抓取网站http状态码
        code=`curl -o /dev/null --retry 3 --retry-max-time 8 -s -w %{http_code} $url`
	curl -X POST -d "[{\"metric\": \"platform.status\", \"endpoint\": \"$hostname\", \"timestamp\": $ts,\"step\": 60,\"value\": $code,\"counterType\": \"GAUGE\",\"tags\": \"module=$url\"}]" http://127.0.0.1:1988/v1/push	
#printf "[{"metric\": \"platform.status\", \"endpoint\": \"$hostname\", \"timestamp\": $ts,\"step\": 60,\"value\": $code,\"counterType\": \"GAUGE\",\"tags\": \"module=$url\"}]"
}
done
 
 
